#!/usr/bin/perl -w

###############################################################################
# Load the study_id and platform in the database
#
# Parameters needed: dbname, username, study, platform
#
# Author: Herodotos Herodotou and Nedyalko Borisov
# Date: May 08, 2010
#
##############################################################################

use getOpts qw(get_options println);

if ($#ARGV != 0)
{
   println qq(Please specify the .properties file);
   println qq(Usage: perl $0 load.properties);
   exit(-1);
}

# Get input parameters
%opt = get_options($ARGV[0]);
$DB_NAME  =$opt{'dbname'};
$USERNAME =$opt{'username'};
$STUDY = $opt{'study'};
$PLATFORM = $opt{'platform'};

# Get the platform
$platform = "";
if ($PLATFORM eq "illumina")
{
  $platform = "i";
}
if ($PLATFORM eq "affymetrix")
{
  $platform = "a";
}

# Do the insert
$sql = "INSERT INTO study_platform(study_id, platform) VALUES('$STUDY',
'$platform')";
!system qq(psql -U $USERNAME -d $DB_NAME -c "$sql" > /dev/null) or die $!;

